<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
</head>
<script>
</script><body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>
        <input type="hidden" name="idxProReleaseDoubleHeavy" id="idxProReleaseDoubleHeavy"/>
        <div class="layui-form-item">
            <label class="layui-form-label">
                开始时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="beginTime" name="beginTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                结束时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="endTime" name="endTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" id="difference">
            <label class="layui-form-label">
                距离结束时间天数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="differenceTime" name="differenceTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" >
            <label for="summaryMeeting1" class="layui-form-label">
                <span class="x-red">*</span>下达双重编号文件上传：<br/>
                <div style="color: #797474;margin-top: 9px;">注：涵盖格式有（word，pdf，jpg）</div>
            </label>
            <div class="layui-input-inline" >
                <a><img class="layui-upload-img" src="" id="imgUrl1" width="100px"/></a>
                <br><br><br>
                <input type="hidden" name="summaryMeeting" id="summaryMeeting1" >
                <button type="button" class="layui-btn" id="upload1">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload1","imgUrl1","summaryMeeting1");
            </script>
                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl2" width="100px"/></a>
                <br><br><br>
                <input type="hidden" name="summaryMeeting" id="summaryMeeting2"   >
                <button type="button" class="layui-btn" id="upload2">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload2","imgUrl2","summaryMeeting2");
            </script>
            </div>
        </div>


        <div class="layui-form-item" id="submitButton">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                保存
            </button>
            <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                预提交
            </button>
            <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                提交
            </button>
        </div>
        <div class="layui-form-item" id="updateStart">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="update" type=button  lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>

    $(function(){
        var index = 33;
        getProTime($("#idxProAdmin").val(),30);
        ajaxFun('get','/pc/project/getDoubleNumberingInfo',{"idProAdmin":$("#idxProAdmin").val()},function(data){
            if(data.code != 0){
                alertFun(data);
            }else{
                if(data.data.submitState === 3){
                    $("#submitButton").hide();
                    $("#updateStart").show();
                    $("#difference").hide();
                }else{
                    $("#submitButton").show();
                    $("#updateStart").hide();
                }
                $("#idxProReleaseDoubleHeavy").val(data.data.idxProReleaseDoubleHeavy);
                for(var i=0;i<data.data.fileIdList.length;i++){
                    $("#imgUrl"+(i+1)).attr("src",getIos(data.data.fileIdList[i].suffixName,data.data.fileIdList[i].filePath));
                    $("#imgUrl"+(i+1)).parent().attr("href",data.data.fileIdList[i].filePath);
                    $("#summaryMeeting"+(i+1)).val(data.data.fileIdList[i].fileId);
                }
            }
        })
    })
    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, layedit = layui.layedit;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(add)', function (t) {
            addSubmit(3);
        });

        //监听保存
        form.on('submit(preservation)', function (t) {
            addSubmit(1);
        });

        //监听预提交
        form.on('submit(preAdd)', function (t) {
            addSubmit(2);
        });

        //修改
        form.on('submit(update)', function (t) {
            addSubmit(10);
        });
    });

    function addSubmit(submitState){
        var myArray=new Array(),i = 0;
        $("input[name='summaryMeeting']").each(function(){
            myArray[i] = $(this).val();
            i++;
        })
        var params = {
            //tcaDescribe : layui.layedit.getContent(index),
            "idProReleaseDoubleHeavy": $("#idxProReleaseDoubleHeavy").val(),
            "idProAdmin": $("#idxProAdmin").val(),
            "submitState":submitState,
            "fileIdList":myArray
        }
        if (true) {
            ajaxFunJson('post','/pc/project/updateDoubleNumbering',JSON.stringify(params),function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    window.location.href = path + "/modules/project/towPro/xdscbh/list.html";
                    console.log("success !");
                }
            })
            return false;
        }
    }
</script></body></html>